from core.support import set_cutscene
from core.item import Item
from core.action import Action

class Fiftyshades(Item):
    def __init__(self):
        Item.__init__(self, "50shades")    # do basic initialization for every item
        self.has_50shades = True
        self.inuse = False
        # build list of actions
        self.add_action(use50shades)
        self.add_action(putaway)
    
    def get_description(self):
        if self.inuse:
            return "The book, 50 Shades of Grey (in use)"
        else:
            return "The book, 50 Shades of Grey"
        
        return "50 Shades"

# define actions for this item

class use50shades(Action):
    def __init__(self):
        Action.__init__(self, "Use 50 Shades")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Use 50 Shades of Grey"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    def is_enabled(self):
        if self.item.inuse:
            return False
        else:
            return True
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        if room.get_id() == 'sea8hearhello': 
            self.item.inuse = True
            set_cutscene("Time to light this up")
            
        else:
            self.item.inuse = True
            set_cutscene("You know, just to pass the time")
        return

class putaway(Action):
    def __init__(self):
        Action.__init__(self, "putaway")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Put away 50 Shades of Grey"
    
    def get_method(self):
        return "post"
    
    def is_enabled(self):
        if self.item.inuse:
            return True
        else:
            return False
    
    def do_action(self,game,room,request):
        self.item.inuse = False
        set_cutscene("Umm, OK.")
        return
        
    
    